/**
 * Copyright (c) 2012, Hakans Pirates - 
 * Johan Andersson spaiki17@gmail.com, 
 * Mattias Lundberg lundberg.mattias@gmail.com, 
 * Samuel Sjodin sjoodin@gmail.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *  
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package pirates;

import com.jme3.input.KeyInput;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.math.Vector3f;
import java.util.HashMap;
import java.util.Map;
import pirates.notifications.Notify;

/**
 * 
 * @author mattias
 */
public class Settings {
	

	// versions
	public static int PROTOCOL_VERSION = 2;
	public static int CLIENT_VERSION = 2;
	public static int SERVER_VERSION = 2;
	// Debug mode
	public static boolean DEBUG = true;
	// Graphics settings
	static public int FRAME_RATE = 60;
	public static boolean FANCY_WATER = true;
	public static boolean DYNAMIC_WATER_FANCINESS = true;
	public static int SHOOT_SPEED = 250;
	public static float BALL_MASS = 100;
	public static final float GRAVITY = -100;
	public static final Vector3f GRAVITY3F = new Vector3f(0, GRAVITY, 0);
	// Game information
	public static String GAME_NAME = "Hakans Pirates";
	public static String HOST_NAME;
	// Network settings
	public static boolean IS_SERVER = false; // set to true if this is the
	// server
	public static int NW_PORT = 48999;
	public static String SERVER_IP_ADDRESS;
	public static int CLIENT_ENTITY_UPDATE_RATE = 100; // milliseconds of waiting time between ship updates are sent
	public static int SERVER_ENTITY_UPDATE_RATE = 20; // milliseconds of waiting time between ai ship updates are sent
	public static boolean SENDING_NW_UPDATES = false;
	// Auth Server settings
	public static String AUTHSERVERS[] = {"hp.netbit.se"};
	public static int REAUTH_RATE = 30;// seconds
	// Models
	public static final String BATTLESHIP_MODEL = "Models/Ships/battle.j3o";
	public static final String FLAGSHIP_MODEL = "Models/Ships/flag.j3o";
	public static final String CRATE_MODEL = "Models/Crates/WoodenBox02.j3o";
	// Node names
	public static final String SHIP_NODE = "ShipNode";
	public static String CAMERA_NODE = "CameraNode";
	public static String CANNON_BALL = "CannonBall";
	// Gameplay settings
	public static float SPAWNING_SAFETY_DISTANCE = 250;
	public static float SPAWN_AREA_RADIUS = 1200;
	public static float COLLISION_FACTOR = 0.05f;
	// public static final float GAME_DURATION =
	public static float TEAM_DISTRIBUTION_PIRATES = 2 / 3; // there will be more brittish ships than pirates
	// Pirate-specific data
	public static Vector3f PirateSpawnPoint = new Vector3f(10000, 0, 2000); // the																// point
	// Brittish-specific data
	public static Vector3f BrittishSpawnPoint = new Vector3f(-4000, 0, 0);
	public static boolean SCENARIO_HAS_STARTED = false;
	public static boolean SCENARIO_HAS_ENDED = false;
	public static int START_CRATES = 25;
	public static EntityTeam winningTeam = null;
	// KeyBindings

	public enum Directions {

		LEFT(1, KeyInput.KEY_A), RIGHT(-1, KeyInput.KEY_D), FORWARD(1,
		KeyInput.KEY_W), BACKWARDS(-1, KeyInput.KEY_S), UP(1,
		KeyInput.KEY_E), DOWN(-1, KeyInput.KEY_Q), DROP(1,
		KeyInput.KEY_1);
		private float value;
		private KeyTrigger keyTrigger;

		private Directions(float value, int keyCode) {
			this.value = value;
			keyTrigger = new KeyTrigger(keyCode);
		}

		public float getValue() {
			return value;
		}

		public KeyTrigger getKeyTrigger() {
			return keyTrigger;
		}
	}
	public static final HashMap battleshipMap = new HashMap(30);

	public static enum ShipConstants {

		ENTITY_MODEL, MODEL_PATH, MAX_SPEED, ACCELERATION, DEACCELERATION, MAX_ANGULAR_ACCELERATION, ANGULAR_ACCELERATION, ANGULAR_DEACCELERATION, SHOOT_RADIUS, SHOOT_HEIGHT, HITPOINTS, TEAM, MAX_CANNON_BALLS, CANNON_BALLS, MAX_HITPOINTS, OWNER;
	}

	public enum EntityModels { // add more on the go

		BATTLESHIP {

			@Override
			protected void initValues() {

				values.put(ShipConstants.ENTITY_MODEL + "", this.toString());
				values.put(ShipConstants.MODEL_PATH + "",
					"Models/Ships/battle.j3o");
				values.put(ShipConstants.HITPOINTS + "", 100f);
				values.put(ShipConstants.MAX_HITPOINTS + "", 100f);
				values.put(ShipConstants.MAX_SPEED + "",
					Float.POSITIVE_INFINITY);
				values.put(ShipConstants.ACCELERATION + "", 40f);
				values.put(ShipConstants.DEACCELERATION + "", 0.1f);
				values.put(ShipConstants.MAX_ANGULAR_ACCELERATION + "", 0.01f);
				values.put(ShipConstants.ANGULAR_ACCELERATION + "", 0.01f);
				values.put(ShipConstants.ANGULAR_DEACCELERATION + "", 20f);
				values.put(ShipConstants.SHOOT_RADIUS + "", 1);
				values.put(ShipConstants.SHOOT_HEIGHT + "", 20);
				values.put(ShipConstants.MAX_CANNON_BALLS + "", 250);
				values.put(ShipConstants.CANNON_BALLS + "", 100);
			}
		},
		FLAGSHIP {

			@Override
			protected void initValues() {
				values.put(ShipConstants.ENTITY_MODEL + "", this.toString());
				values.put(ShipConstants.MODEL_PATH + "",
					"Models/Ships/flag.j3o");
				values.put(ShipConstants.HITPOINTS + "", 100f);
				values.put(ShipConstants.MAX_HITPOINTS + "", 100f);
				values.put(ShipConstants.MAX_SPEED + "",
					Float.POSITIVE_INFINITY);
				values.put(ShipConstants.ACCELERATION + "", 40f);
				values.put(ShipConstants.DEACCELERATION + "", 0.1f);
				values.put(ShipConstants.MAX_ANGULAR_ACCELERATION + "", 0.01f);
				values.put(ShipConstants.ANGULAR_ACCELERATION + "", 0.01f);
				values.put(ShipConstants.ANGULAR_DEACCELERATION + "", 20f);
				values.put(ShipConstants.SHOOT_RADIUS + "", 1);
				values.put(ShipConstants.SHOOT_HEIGHT + "", 20);
				values.put(ShipConstants.MAX_CANNON_BALLS + "", 250);
				values.put(ShipConstants.CANNON_BALLS + "", 100);
			}
		},
		BIRD {

			@Override
			protected void initValues() {
			}
		};
		protected Map<String, Object> values = new HashMap<String, Object>(30);

		private EntityModels() {
			initValues();
		}

		abstract protected void initValues();

		public Map<String, Object> getValues() {
			return values;
		}
	}

	public enum EntityTeam {

		PIRATES, BRITISH, NEUTRAL;
		private Map<String, Object> values = new HashMap<String, Object>(30);

		private EntityTeam() {
			values.put(ShipConstants.TEAM + "", toString());
		}

		public Map<String, Object> getValues() {
			return values;
		}
	}

	public static void main(String[] args) {

		testEntityTeam();
	}

	private static void testEntityTeam() {
		Notify.debug(EntityTeam.BRITISH.getValues().toString());
		Notify.debug(EntityTeam.PIRATES.getValues().toString());
	}
}
